package aapilast1;

public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread("林一") {
            public void run() {
                System.out.println(getName() + "lin开始执行...");
                try {
                    Thread.sleep(1000000000);
                } catch (InterruptedException e) {
                    System.out.println(getName() + "lin被中断了...");
                }
                System.out.println(getName() + "lin执行结束...");
            }
        };
        Thread huang = new Thread("黄二") {
            public void run() {
                System.out.println(getName() + "huang开始执行...");
                for (int i = 0; i < 5; ++i) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(getName() + "huang执行结束...");
                lin.interrupt();
            }
        };
        lin.start();
        huang.start();
    }
}
